package com.example.review_generator

import android.content.Context
import android.os.Bundle
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.fragment.app.Fragment
import kotlinx.android.synthetic.main.select_fragment.*

class Information_select:Fragment() {


    override fun onCreateView(inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle?): View? {

        return inflater!!.inflate(R.layout.select_fragment,container,false)
    }

    override fun onPause() {
        super.onPause()
        save_data()
    }




    fun save_data(){
        //调用主活动
        var ma:MainActivity= activity as MainActivity

        if(input_name.text.toString().isNotEmpty()){
            ma.name= input_name.text.toString()
        }
        if(input_place.text.toString().isNotEmpty()){
            ma.place= input_place.text.toString()
        }
        if(input_to_who.text.toString().isNotEmpty()){
            ma.to_who= input_to_who.text.toString()
        }
        if(input_thing.text.toString().isNotEmpty()){
            ma.thing= input_thing.text.toString()
        }
        if(input_num.text.toString().trim()!=""){
            ma.num=input_num.text.trim().toString().toInt()
        }

    }

}